﻿@model  Model.CodeManage.BindCodeModel 
@{
    Layout = "~/Views/Shared/MyLayOutNew.cshtml";
}
<link rel="stylesheet" type="text/css" href="~/css/style.css" />

<script src="~/javascript/jquery.js"></script>
<main class="main-cont content mCustomScrollbar">
   @using(Html.BeginForm("SaveData","BindCode",FormMethod.Post)){
        <div class="page-wrap">
            <!--开始::内容-->
            <section class="page-hd">
                <header>
                    <h2 class="title">输入版号</h2>

                </header>
                <hr>
            </section>
                <input type="text" name="TempletId" value="@ViewBag.id" hidden="hidden">
            <input type="text" name="EnterpriseId" value="@ViewBag.EnterpriseId" hidden="hidden">
           
            <div class="form-group-col-2">
                <div class="form-label"></div>
                <div class="form-cont">
                    <label class="check-box">
                        <input type="checkbox" checked="checked" name="IsContinuous" value="true" id="checkBox1" />
                        <span>连续码</span>
                    </label>
                    <label class="check-box">
                        <input type="checkbox" name="IsContinuous" value="false" id="checkBox2" />
                        <span>不连续</span>
                    </label>

                </div>
            </div>
            <div class="form-group-col-2" id="div1" >
                <div class="form-label">输入版号：</div>
                <div class="form-cont">
                    <input type="text" placeholder="多个版号用英文','隔开" class="form-control form-boxed" id="BS" name="BS" >

                </div>
            </div>
            <div class="form-group-col-2" id="div2">
                <div class="form-label">开始板号：</div>
                <div class="form-cont">
                    <input type="text" placeholder="请纸张上的字符" class="form-control form-boxed" id="StartBS" name="StartBS" >

                </div>
            </div>
            <div class="form-group-col-2" id="div3">
                <div class="form-label">结束版号：</div>
                <div class="form-cont">
                    <input type="text" placeholder="请纸张上的字符" class="form-control form-boxed" id="EndBS" name="EndBS">

                </div>
            </div>
            <div class="form-group-col-2">
                <div class="form-label"></div>
                <div class="form-cont">
                    <input type="submit" class="btn btn-primary" value="提交表单" />
                    <input type="reset" class="btn btn-disabled" value="禁止" />
                </div>
            </div>
            <!--开始::结束-->
            <div class="panel-bd">
                <div class="btn btn-info JopenPanel mr-10" style="display:none" id="buttun">弹框按钮</div>
              
            </div>

            <div class="mask"></div>
            <div class="dialog">
                <div class="dialog-hd">
                    <strong class="lt-title">温馨提示</strong>
                    <a class="rt-operate icon-remove JclosePanel" title="关闭"></a>
                </div>
                <div class="dialog-bd">
                    <!--start::-->
                    <p></p>
                    <!--end::-->
                </div>
                <div class="dialog-ft">
                    <div class="btn btn-info JyesBtn">确认</div>
                    <div class="btn btn-secondary JnoBtn">关闭</div>
                </div>
            </div>

        </div>
   }
</main>
<script type="text/javascript">
    $("#div1").css("display", "none");
   
    //单选按钮
    $("#checkBox1").click(function (e) {//连续版号
  
            $("#checkBox1")["0"].checked = true;
            $("#checkBox2")["0"].checked = false;
            $("#div1").css("display", "none");
            $("#div2").css("display", "");
            $("#div3").css("display", "");

        
    });
   
    $("#checkBox2").click(function (e) {//非连续版号
          
        $("#checkBox2")["0"].checked = true;
        $("#checkBox1")["0"].checked = false;
        $("#div1").css("display", "");
        $("#div2").css("display", "none");
        $("#div3").css("display", "none");
    });


    //提交前验证
    $(document).ready(function () {
        $('form').bind('submit', checkform);
    });

    function checkform() {
     
        var TName = "";
        if ($("#checkBox2")["0"].checked) {
            var bs = $("#BS").val().split('/');
            TName=bs[0];
        }
        else {
            var starts = $("#StartBS").val().split('/');
            var ends = $("#EndBS").val().split('/');
            if (starts[0] != ends[0]) {
                $(".dialog-bd p").html("两个版号批次不一样！请核对/前数字是否一致！");
                $("#buttun").trigger("click");
                return false;
            }
            TName = starts[0];
        }
        var bool=false;
        $.ajax({
            url: '/BindCode/IsExistWL?TName=' + TName,
            type: 'post',
            success: function (t) {
                if (t)  bool=t;
                else {
                    $(".dialog-bd p").html("物流码不存在，无法绑定！");
                    $("#buttun").trigger("click");
                    bool = false;
                   // return false;
                } 
            }
        });
        return bool;
    }
</script>